//package com.dykj.fireFighting.web.mq.consumer.business;
//
//import com.alibaba.fastjson.JSON;
//import com.dykj.fireFighting.api.elasticsearch.devHis.entity.EsDevHis;
//import com.dykj.fireFighting.api.elasticsearch.devHisWater.entity.EsDevHisWater;
//import com.dykj.fireFighting.api.elasticsearch.devHisWater.service.EsDevHisWaterService;
//import com.dykj.fireFighting.common.starter.redisson.service.RedisService;
//import com.dykj.fireFighting.web.model.report.DevHisWater;
//import com.dykj.fireFighting.web.service.DevHisService;
//import com.dykj.fireFighting.web.utils.SpringUtil;
//import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
//import org.apache.rocketmq.common.message.Message;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
//
//import java.io.UnsupportedEncodingException;
//
//
///**
// * @Author fgc
// * @Date 2021/9/30 10:12
// * @ Description：MQ消息业务处理--设备运行记录入库
// */
//public class InsertDevHisWater extends BusinessProcess{
//    public static final Logger LOGGER = LoggerFactory.getLogger(InsertDevHisWater.class);
//    private static RedisService redisService=(RedisService) SpringUtil.getBean(RedisService.class);
//    private static DevHisService devHisService=(DevHisService) SpringUtil.getBean(DevHisService.class);
//    private static EsDevHisWaterService esDevHisWaterService=(EsDevHisWaterService)SpringUtil.getBean("esDevHisWaterService");
//    public InsertDevHisWater(){
//        super();
//    }
//    @Override
//    public ConsumeConcurrentlyStatus process(Message msg){
//        LOGGER.info("进入插入水设备运行记录业务实现");
//        String msgBody= null;
//        try {
//            msgBody = new String (msg.getBody(),"utf-8");
//            DevHisWater devHisWater = JSON.parseObject(msgBody, DevHisWater.class);
//            LOGGER.info("===========插入EsDevHisWater数据到mysql==============");
//            devHisService.insertDevHisWater(devHisWater);
//            LOGGER.info("===========插入EsDevHisWater数据到ES==============");
//            EsDevHisWater esDevHisWater = new EsDevHisWater();
//            BeanUtils.copyProperties(devHisWater, esDevHisWater);
//            esDevHisWater.setUnitId(devHisWater.getUnitId());
//            esDevHisWater.setDeviceName(devHisWater.getDeviceName());
//            esDevHisWaterService.importAll(esDevHisWater);
//            LOGGER.info("===========插入EsDevHisWater数据到ES:=============" + JSON.toJSONString(esDevHisWater));
//            redisService.set(devHisWater.getId(), JSON.toJSONString(devHisWater), 3600l);
//            return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
//        } catch (UnsupportedEncodingException e) {
//            e.printStackTrace();
//            return ConsumeConcurrentlyStatus.RECONSUME_LATER;
//        }
//
//    }
//
//}
